package com.zhz.controller;

import com.zhz.bean.User;
import com.zhz.service.UserService;
import com.zhz.springmvc.annotation.Autowired;
import com.zhz.springmvc.annotation.Controller;
import com.zhz.springmvc.annotation.RequestMapping;
import com.zhz.springmvc.annotation.ResponseBody;

/**
 * @author ：zhz
 * @date ：Created in 2021/01/03
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description:
 **/
@Controller
public class UserController {

    @Autowired(value = "userService")
    private UserService userService;

    @RequestMapping("/listUsers")
    public String listUsers(){
        userService.listUsers();
        return "forward:/success.jsp";
    }

    @RequestMapping("/getData")
    @ResponseBody  //返回json格式的数据
    public User getData(){
        //调用服务层
        return userService.getUser();
    }

}
